<?php 
/**************************************************/
## Class Name - Model_CMS (Contains all the functions related cms pages of the project)
## Created By - Techmodi (19/08/2011)
/**************************************************/

class Model_CMS extends Database
{	
	function Model_CMS() {	
		$this->cms = CMS;
		$this->seo = SEO;
		$this->Database();
	}
	
	// Add CMS Page
	function addSubmenu($array) {
		$this->InsertData($this->cms, $array);
	}
	
	// Update default SEO
	function updateDefaultSeo($array, $Id){
		$this->UpdateData($this->seo,$array,"id",$Id,0);
	}
	
	## List all submenus
	function getAllSubMenu($search='',$col1="",$limit='',$offset='') {
		$fields = array();	
		$tables = array($this->cms);
		if($col1=='1')
			$order = array("submenu_title DESC");
		
		$result1 = $this->SelectData($fields,$tables, $where= array("submenu_title LIKE '%".$search."%'"), $order , $group=array(),$limit,$offset,0); 
		$result  = $this->FetchAll($result1); 
		return $result;
	}
	
	## Get submenu details by id
	function getSubmenuDetailsById($submenu_id) {
		$fields = array();	
		$tables = array($this->cms);
		$result1 = $this->SelectData($fields,$tables, $where= array("submenu_id='".$submenu_id."'"), $order = array(), $group=array(),$limit = "",0,0); 
		$result  = $this->FetchRow($result1); 
		return $result;
	}
	
	## Get submenu details by id
	function getfeDefaultSeo() {
		$fields = array();	
		$tables = array($this->seo);
		$result1 = $this->SelectData($fields,$tables, $where= array("id=1"), $order = array(), $group=array(),$limit = "",0,0); 
		$result  = $this->FetchRow($result1); 
		return $result;
	}
	
	
	## Edit menu by id
	function editUserCmsById($array, $Id){
		$this->UpdateData($this->cms,$array,"submenu_id",$Id,0);
	}
	
	## Update cms page status with multiple ids
	function updateMultipleCmsStatus($ids, $status) {
		$sql = "UPDATE ".$this->cms." SET status='".$status."' WHERE submenu_id IN (".$ids.")";
		$result1= $this->ExecuteQuery($sql);	 
		
	}
	
	## Get submenu details by id
	function getDetailsSeoById($id) {
		$fields = array();	
		$tables = array($this->seo);
		$result1 = $this->SelectData($fields,$tables, $where= array("id='".$id."'"), $order = array(), $group=array(),$limit = "",0,0); 
		$result  = $this->FetchRow($result1); 
		return $result;
	}


}
?>


